/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/domain/{{entities@SQL}}.java.hbs
 */
package cn.ibizlab.core.authorization.domain;

import java.util.*;
import cn.ibizlab.util.domain.IEntity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.*;
import org.springframework.data.annotation.*;
import cn.ibizlab.util.annotation.*;
import cn.ibizlab.util.enums.*;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import cn.ibizlab.core.ad.domain.SysCommonName;
import cn.ibizlab.core.authorization.domain.SysRole;

/**
 * 系统角色成员实体类[SysRoleMember]
 *
 * @author generator
 */
@Audit
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@TableName(value = "SYS_ROLE_MEMBER", resultMap = "SysRoleMemberResultMap")
@ApiModel(value = "SYS_ROLE_MEMBER", description = "系统角色成员")
public class SysRoleMember extends EntityMP implements Serializable
{

    /**
     * 标识
     */
    @Id
    @TableId(value = "id" , type = IdType.ASSIGN_UUID)
    @DEField(name = "id" , isKeyField = true)
    @JsonProperty("id")
    @JSONField(name = "id")
    @ApiModelProperty(value = "id", notes = "标识")
    private String id;

    /**
     * 创建人
     */
    @TableField(value = "creator" , fill = FieldFill.INSERT)
    @DEField(name = "creator" , preType = DEPredefinedFieldType.CREATEMAN)
    @JsonProperty("creator")
    @JSONField(name = "creator")
    @ApiModelProperty(value = "creator", notes = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @TableField(value = "create_time" , fill = FieldFill.INSERT)
    @DEField(name = "create_time" , preType = DEPredefinedFieldType.CREATEDATE)
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "create_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "create_time", notes = "创建时间")
    private Date createTime;

    /**
     * 最后更新人
     */
    @TableField(value = "updater")
    @DEField(name = "updater" , preType = DEPredefinedFieldType.UPDATEMAN)
    @JsonProperty("updater")
    @JSONField(name = "updater")
    @ApiModelProperty(value = "updater", notes = "最后更新人")
    private String updater;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time")
    @DEField(name = "update_time" , preType = DEPredefinedFieldType.UPDATEDATE)
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "update_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "update_time", notes = "最后更新时间")
    private Date updateTime;

    /**
     * DC
     */
    @TableField(value = "dc")
    @DEField(name = "dc")
    @JsonProperty("dc")
    @JSONField(name = "dc")
    @ApiModelProperty(value = "dc", notes = "DC")
    private String dc;

    /**
     * 系统角色标识
     */
    @TableField(value = "role_id")
    @Audit
    @DEField(name = "role_id")
    @JsonProperty("role_id")
    @JSONField(name = "role_id")
    @ApiModelProperty(value = "role_id", notes = "系统角色标识")
    private String roleId;

    /**
     * 成员类型
     */
    @TableField(value = "member_type")
    @Audit
    @DEField(name = "member_type" , dict = "Sys_cn_type")
    @JsonProperty("member_type")
    @JSONField(name = "member_type")
    @ApiModelProperty(value = "member_type", notes = "成员类型")
    private String memberType;

    /**
     * 用户组/人员标识
     */
    @TableField(value = "member_uid")
    @Audit
    @DEField(name = "member_uid")
    @JsonProperty("member_uid")
    @JSONField(name = "member_uid")
    @ApiModelProperty(value = "member_uid", notes = "用户组/人员标识")
    private String memberUid;

    /**
     * 成员名称
     */
    @TableField(value = "member_name")
    @Audit
    @DEField(name = "member_name")
    @JsonProperty("member_name")
    @JSONField(name = "member_name")
    @ApiModelProperty(value = "member_name", notes = "成员名称")
    private String memberName;

    /**
     * 成员DN
     */
    @TableField(value = "member_dn")
    @DEField(name = "member_dn")
    @JsonProperty("member_dn")
    @JSONField(name = "member_dn")
    @ApiModelProperty(value = "member_dn", notes = "成员DN")
    private String memberDn;

    /**
     * 成员分组标识
     */
    @TableField(value = "member_group_id")
    @DEField(name = "member_group_id")
    @JsonProperty("member_group_id")
    @JSONField(name = "member_group_id")
    @ApiModelProperty(value = "member_group_id", notes = "成员分组标识")
    private String memberGroupId;

    /**
     * 成员分组名称
     */
    @TableField(value = "member_group_name" , exist = false)
    @DEField(name = "member_group_name")
    @JsonProperty("member_group_name")
    @JSONField(name = "member_group_name")
    @ApiModelProperty(value = "member_group_name", notes = "成员分组名称")
    private String memberGroupName;

    /**
     * 部门标识
     */
    @TableField(value = "department_id")
    @DEField(name = "department_id")
    @JsonProperty("department_id")
    @JSONField(name = "department_id")
    @ApiModelProperty(value = "department_id", notes = "部门标识")
    private String departmentId;

    /**
     * 组织机构标识
     */
    @TableField(value = "organization_id")
    @DEField(name = "organization_id")
    @JsonProperty("organization_id")
    @JSONField(name = "organization_id")
    @ApiModelProperty(value = "organization_id", notes = "组织机构标识")
    private String organizationId;

    /**
     * Mail
     */
    @TableField(value = "mail" , exist = false)
    @DEField(name = "mail")
    @JsonProperty("mail")
    @JSONField(name = "mail")
    @ApiModelProperty(value = "mail", notes = "Mail")
    private String mail;

    /**
     * 系统角色名称
     */
    @TableField(value = "role_name" , exist = false)
    @Audit
    @DEField(name = "role_name")
    @JsonProperty("role_name")
    @JSONField(name = "role_name")
    @ApiModelProperty(value = "role_name", notes = "系统角色名称")
    private String roleName;

    /**
     * 角色标记
     */
    @TableField(value = "role_authority" , exist = false)
    @Audit
    @DEField(name = "role_authority")
    @JsonProperty("role_authority")
    @JSONField(name = "role_authority")
    @ApiModelProperty(value = "role_authority", notes = "角色标记")
    private String roleAuthority;

    /**
     * 系统标识
     */
    @TableField(value = "deploy_system_id" , exist = false)
    @DEField(name = "deploy_system_id")
    @JsonProperty("deploy_system_id")
    @JSONField(name = "deploy_system_id")
    @ApiModelProperty(value = "deploy_system_id", notes = "系统标识")
    private String deploySystemId;

    /**
     * CN
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "common_name", notes = "用户组/人员")
    private SysCommonName commonName;

    /**
     * 系统角色
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "role", notes = "系统角色")
    private SysRole role;

    /**
     * 设置 [DC]
     */
    public SysRoleMember setDc(String dc) {
        this.dc = dc;
        this.modify("dc", dc);
        return this;
    }

    /**
     * 设置 [系统角色标识]
     */
    public SysRoleMember setRoleId(String roleId) {
        this.roleId = roleId;
        this.modify("role_id", roleId);
        return this;
    }

    /**
     * 设置 [成员类型]
     */
    public SysRoleMember setMemberType(String memberType) {
        this.memberType = memberType;
        this.modify("member_type", memberType);
        return this;
    }

    /**
     * 设置 [用户组/人员标识]
     */
    public SysRoleMember setMemberUid(String memberUid) {
        this.memberUid = memberUid;
        this.modify("member_uid", memberUid);
        return this;
    }

    /**
     * 设置 [成员名称]
     */
    public SysRoleMember setMemberName(String memberName) {
        this.memberName = memberName;
        this.modify("member_name", memberName);
        return this;
    }

    /**
     * 设置 [成员DN]
     */
    public SysRoleMember setMemberDn(String memberDn) {
        this.memberDn = memberDn;
        this.modify("member_dn", memberDn);
        return this;
    }

    /**
     * 设置 [成员分组标识]
     */
    public SysRoleMember setMemberGroupId(String memberGroupId) {
        this.memberGroupId = memberGroupId;
        this.modify("member_group_id", memberGroupId);
        return this;
    }

    /**
     * 设置 [成员分组名称]
     */
    public SysRoleMember setMemberGroupName(String memberGroupName) {
        this.memberGroupName = memberGroupName;
        this.modify("member_group_name", memberGroupName);
        return this;
    }

    /**
     * 设置 [部门标识]
     */
    public SysRoleMember setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
        this.modify("department_id", departmentId);
        return this;
    }

    /**
     * 设置 [组织机构标识]
     */
    public SysRoleMember setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
        this.modify("organization_id", organizationId);
        return this;
    }

    /**
     * 设置 [Mail]
     */
    public SysRoleMember setMail(String mail) {
        this.mail = mail;
        this.modify("mail", mail);
        return this;
    }

    /**
     * 设置 [系统角色名称]
     */
    public SysRoleMember setRoleName(String roleName) {
        this.roleName = roleName;
        this.modify("role_name", roleName);
        return this;
    }

    /**
     * 设置 [角色标记]
     */
    public SysRoleMember setRoleAuthority(String roleAuthority) {
        this.roleAuthority = roleAuthority;
        this.modify("role_authority", roleAuthority);
        return this;
    }

    /**
     * 设置 [系统标识]
     */
    public SysRoleMember setDeploySystemId(String deploySystemId) {
        this.deploySystemId = deploySystemId;
        this.modify("deploy_system_id", deploySystemId);
        return this;
    }


    @Override
    public Serializable getDefaultKey(boolean gen) {
        //Assert.notNull(getRoleId(),"未设置系统角色标识");
        //Assert.notNull(getMemberUid(),"未设置用户组/人员标识");
        String key = String.format("%s||%s"
            ,getRoleId(),getMemberUid());
        key = DigestUtils.md5DigestAsHex(key.getBytes());    
        return key;
    }

    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param includeEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T pasteTo(T targetEntity, boolean includeEmpty) {
        super.pasteTo(targetEntity, includeEmpty);
        if(targetEntity instanceof IEntity) {
            IEntity entity = ((IEntity) targetEntity);
            entity.reset("id");
        }
        return targetEntity;
    }

}